package com.laomuji.android.mvvm.utils

import android.app.Activity
import android.content.Context
import android.content.ContextWrapper
import com.laomuji.android.mvvm.base.BaseActivity
import com.laomuji.android.mvvm.base.BaseApplication

/**
 * 提供一些Context相关操作
 * @author laomuji666
 * @since 2024/2/20
 */
object PackageUtil {
    /**
     * 获取Application的Context
     */
    fun getApplicationContext(): Context {
        return BaseApplication.instance!!
    }

    /**
     * 获取当前栈顶Activity
     */
    fun getTopActivity(): BaseActivity<*, *> {
        return BaseApplication.instance!!.getTopActivity()
    }

    /**
     * 获取所有Activity
     */
    fun getAllActivity():List<BaseActivity<*, *>>{
        return BaseApplication.instance!!.activityList
    }

    /**
     * 获取包名
     */
    fun getPackageName(): String {
        return getApplicationContext().packageName
    }
}